//
//  JgAdsRewardedVideoCustomEvent.m
//  AnyThinkSDKDemo
//
//  Created by 刘娟 on 2022/10/17.
//  Copyright © 2022 抽筋的灯. All rights reserved.
//

#import "JgAdsRewardedVideoCustomEvent.h"

@implementation JgAdsRewardedVideoCustomEvent

-(void)loadRawardVodWithPosId:(NSString *)posId{
    self->_expressRvAdContainer = [[JgAdsRewardVodAdContainer alloc] initPosId:posId delegate:self];
    [self->_expressRvAdContainer loadRewardVodAd];
}

-(void)showFromRootViewController:(UIViewController *)controller{
    [self.expressRvAdContainer showRewardVodAdWithRootViewController:controller];
}

/**
 *  激励视频广告数据请求成功
 */
- (void)jgadsRewardVodAdSuccessToLoadAd:(JgAdsRewardVodAd *)rewardVodAd{
    [self trackRewardedVideoAdLoaded:self.expressRvAdContainer adExtra:nil];
}

/**
 *  激励视频广告数据请求失败
 */
- (void)jgadsRewardVodAdFailToLoadAd:(JgAdsRewardVodAd *)rewardVodAd error:(NSError *)error{
    [self.expressRvAdContainer close];
    [self trackRewardedVideoAdLoadFailed:error];
}

/**
 *  激励视频广告视频缓存成功
 */
- (void)jgadsRewardVodAdVideoCacheFinish:(JgAdsRewardVodAd *)rewardVodAd{}

/**
 *  激励视频广告渲染成功
 *  建议在此回调后展示广告
 */
- (void)jgadsRewardVodAdVideoReadyToPlay:(JgAdsRewardVodAd *)rewardVodAd{}

/**
 *  激励视频广告播放失败
 *
 */
- (void)jgadsRewardVodAdVideoPlayFail:(JgAdsRewardVodAd *)rewardVodAd error:(NSError *)error{
    [self trackRewardedVideoAdPlayEventWithError:error];
}

/**
 *  激励视频视图展示成功回调
 *  激励视频展示成功回调该函数
 */
- (void)jgadsRewardVodAdDidPresentScreen:(JgAdsRewardVodAd *)rewardVodAd{
    [self trackRewardedVideoAdVideoStart];
}

/**
 *  激励视频广告视图展示失败回调
 *  激励视频广告展示失败回调该函数
 */
- (void)jgadsRewardVodAdFailToPresent:(JgAdsRewardVodAd *)rewardVodAd error:(NSError *)error{
    [self.expressRvAdContainer close];
}

/**
 *  激励视频广告曝光回调
 */
- (void)jgadsRewardVodAdWillExposure:(JgAdsRewardVodAd *)rewardVodAd{
    [self trackRewardedVideoAdShow];
}

/**
 *  激励视频广告点击回调
 */
- (void)jgadsRewardVodAdClicked:(JgAdsRewardVodAd *)rewardVodAd{
    [self trackRewardedVideoAdClick];
}

/**
 *  激励视频广告页关闭
 */
- (void)jgadsRewardVodAdAdDidDismissClose:(JgAdsRewardVodAd *)rewardVodAd{
    //因为极光ads广告不支持服务端验证，所以默认传入YES
    [self.expressRvAdContainer close];
    [self trackRewardedVideoAdCloseRewarded:YES extra:nil];
}

/**
 *  激励视频广告达到激励条件
 */
- (void)jgadsRewardVodAdAdDidEffective:(JgAdsRewardVodAd *)rewardVodAd{
    [self trackRewardedVideoAdRewarded];
}

/**
 *  激励视频广告视频播放结束
 */
- (void)jgadsRewardVodAdAdVideoPlayFinish:(JgAdsRewardVodAd *)rewardVodAd{
    [self trackRewardedVideoAdVideoEnd];
}

/**
 *  激励视频广告关闭落地页
 */
- (void)jgadsRewardVodAdCloseLandingPage:(JgAdsRewardVodAd *)rewardVodAd{
    
}

@end
